﻿using System;

namespace ForgeCraft
{
    public class CmdDrawDistance : Command
    {
        public override string name { get { return "drawdistance"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "other"; } }
        public override bool consoleUsable { get { return false; } }
        public override Permission defaultRank { get { return Permission.Guest; } }
        public CmdDrawDistance() { }

        public override void Use(Player p, string message)
        {

            if (!p.info.group.drawLimitLocked)
            {
                p.Message(Color.Sys + "Your draw distance is currently locked!");
                return;

            }

            if (message == "")
            {
                p.Message(Color.Sys + "Draw Distance is set to: " + Color.Help + p.ChunkAreaPlayer);
                return;
            }

            int range = -1;

            int.TryParse(message, out range);

            if (range < 6 && range > 30)
            {
                p.Message(Color.Sys + "You must choose a value between 6 and 20");
            }
            else
            {
                p.Message(Color.Sys + "Range is now set to: " + Color.Help + p.ChunkAreaPlayer);

                p.ChunkAreaPlayer = range;
                p.UpdateChunks();              
            }

        }
        public override void Help(Player p)
        {
            p.Message(Color.Aqua + "/setarea " + Color.Help + "- Changes view distance");
        }
    }
}